package com.yilu.driver.mvp.presenter;


import android.content.Context;

import com.is.common.retrofitrxcache.RxCacheResult;
import com.is.common.rx.RxSubscriber;
import com.yilu.driver.entity.BatchAllResponse;
import com.yilu.driver.entity.StudentApplyResponse;
import com.yilu.driver.mvp.contract.ApplyExamContract;

import org.json.JSONObject;


/**
 * 报考登记
 * @author Administrator
 * @date 2017/4/13 0013
 */

public class ApplyExamPresenter extends ApplyExamContract.Presenter {
    private Context mContext;

    public ApplyExamPresenter(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public void getApplyStudent(JSONObject json) {
        mRxManager.add(mModel.getApplyStudent(json).subscribe(new RxSubscriber<RxCacheResult<StudentApplyResponse>>(mContext, false) {
            @Override
            protected void _onNext(RxCacheResult<StudentApplyResponse> rxCacheResult) {
                mView.returnApplyStudent(rxCacheResult.getResultModel());
            }

            @Override
            protected void _onError(String message) {

            }
        }));
    }

    @Override
    public void getExamRoster(JSONObject json) {
        mRxManager.add(mModel.getExamRoster(json).subscribe(new RxSubscriber<RxCacheResult<StudentApplyResponse>>(mContext, false) {
            @Override
            protected void _onNext(RxCacheResult<StudentApplyResponse> result) {
                mView.returnExamRoster(result.getResultModel());
            }

            @Override
            protected void _onError(String message) {

            }
        }));
    }

    @Override
    public void getBatchAll(JSONObject json) {
        mRxManager.add(mModel.getBatchAll(json).subscribe(new RxSubscriber<RxCacheResult<BatchAllResponse>>(mContext, false) {
            @Override
            protected void _onNext(RxCacheResult<BatchAllResponse> batchAllResponseRxCacheResult) {
                mView.returnBatchAll(batchAllResponseRxCacheResult.getResultModel());
            }

            @Override
            protected void _onError(String message) {

            }
        }));
    }
}
